<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>  


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8;" />
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<meta http-equiv="X-UA-Compatible" content="IE=Edge,Chrome=1"/> 
<meta name="renderer" content="webkit"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<base target="_top" />
<title>创新评测报告</title>
	<link href="<%=basePath%>css/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
	<link href="<%=basePath%>css/basic.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="<%=basePath%>css/pagination.css">
	<script type="text/javascript" src="<%=basePath%>js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>css/bootstrap/js/bootstrap.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/echarts-2.2.7/build/dist/echarts.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/jquery.pagination.js"></script>


 	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

 
</head>
<script>


</script>
<body>
<div class="top">
<div class="container">
	<img alt="140x140" src="<%=basePath%>images/logo.jpg" />
</div>
</div>
<div class="row show-grid daohang">
<div class="container">
	<a href="<%=basePath%>page/evaluate.jsp"><div class="daohang-name"><strong>评测首页</strong></div></a>
	<a href="#"><div class="daohang-name this"><strong>模板列表</strong></div></a>
	
</div>
</div>
<div class="container">
		<div class="col-md-12 column">
			<h3 class="text-center">
				<strong>模板列表</strong>
			</h3>
			<hr/>
	<div class="col-md-12 column">
	 <a class="list btn btn-success" href="<%=basePath%>template/getCategoryAll">增加模板</a>
	<table class="table  table-striped">
  <thead>
    <tr>
      <th>编号</th>
      <th>模板名称</th>
      <th>修改日期</th>
      <th>查看/修改</th>
      <th>删除</th>
      <th>使用</th>
      
    </tr>
  </thead>
  <tbody>

  </tbody>
</table>
		</div>
        <div id="pagination" class="pagination"></div>
	</div>
</div>

   
</body>
<script type="text/javascript">
	function dele(templateId){
		 if (confirm("你确定删除吗？")) {
			 $.ajax({
				 type: "Post",
				 url: "<%=basePath%>template/deleTemplate?templateId="+templateId,
				 data: {},
				 success: function (data) {
					 if(data>0){
						 alert("删除成功");
						 window.location.reload();
					 }else{
						 alert("删除失败");
					 }

				 },

			 });


	    }  
	    else {  
	         
	   	 }  
		}

    $(function () {
        var pageCount=${templatecount};  //分页总数量
        // $("#pagination").pagination(pageCount); //简单初始化方法


        $(".pagination").pagination(pageCount,    //分布总数量，必须参数
                {
                    callback: PageCallback,  //PageCallback() 为翻页调用次函数。
                    prev_text: "« 上一页",
                    next_text: "下一页 »",
                    items_per_page:10,
                    num_edge_entries: 2,       //两侧首尾分页条目数
                    num_display_entries: 3,    //连续分页主体部分分页条目数
                    current_page: 0 ,  //当前页索引
                    load_first_page:true

                });

    });

    function PageCallback(page_index,jq)
    {
        $.ajax({
            type: "GET",
            dataType: "json",
            url: '<%=basePath%>template/selectTemplateByPage?pageNum='+ (page_index+1) +'&pageSize=10',      //提交到一般处理程序请求数据
            success: function(data) {
                $('table').find('tr').each(function(i){
                    if(i > 0){
                        $(this).remove();
                    }
                })
                $.each(data.list, function (i,val) {
                    $('table').append('<tr><td>'+(i+1)+'</td><td>'+val.templateName+'</td><td>'+val.modifyTime+'</td><td><a href="<%=basePath%>template/getCategoryAndTemplate?templateId='+val.id+'" >查看/修改</a></td><td><a href="#" onclick="dele('+val.id+')">删除</a></td><td><a href="<%=basePath%>evaluation/useTemplate?templateId='+val.id+'">使用</a></td></tr>'
                    );
                })

            }
        });
    }
</script>
</html>
